export function generateChartOptions(chartType, chartData) {
  const baseOptions = {
    title: {
      text: chartData?.title || '',
      left: 'center'
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: chartData?.legend || [],
      bottom: 0
    }
  };

  switch (chartType) {
    case 'line':
      return {
        ...baseOptions,
        xAxis: {
          type: 'category',
          data: chartData?.xAxis || []
        },
        yAxis: {
          type: 'value'
        },
        series: chartData?.series.map(item => ({
          ...item,
          type: 'line'
        }))
      };

    case 'bar':
      return {
        ...baseOptions,
        xAxis: {
          type: 'category',
          data: chartData?.xAxis || []
        },
        yAxis: {
          type: 'value'
        },
        series: chartData?.series.map(item => ({
          ...item,
          type: 'bar'
        }))
      };

    case 'pie':
      return {
        ...baseOptions,
        series: [{
          type: 'pie',
          radius: '50%',
          data: chartData.series[0].data || [],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }]
      };

    case 'scatter':
      return {
        ...baseOptions,
        xAxis: {
          type: 'value'
        },
        yAxis: {
          type: 'value'
        },
        series: chartData.series.map(item => ({
          ...item,
          type: 'scatter'
        }))
      };

    default:
      console.error('Unsupported chart type');
      return {};
  }
}